import 'package:flutter/material.dart';

//无状态 进度条的加载 组件
class LoadingContainer extends StatelessWidget {
  final Widget child;
  final bool isLoading;
  final bool cover;

  const LoadingContainer({Key? key, required this.child, required this.isLoading, this.cover = false}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return !cover
        ? !isLoading ? child : _loadingView
        : Stack(
            children: <Widget>[child, isLoading ? _loadingView : Container()],
        );
  }
}

Widget get _loadingView {
  return Center(
    child: CircularProgressIndicator(),
  );
}
